<template>
  <a-card :bordered="false" title="">
    <a-table
      ref="table"
      size="middle"
      :scroll="{x:true}"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      class="j-table-force-nowrap1"
      @change="handleTableChange">

      <template slot="content" slot-scope="text,record">
        <div v-if="record.ago==null&&record.after!=null">{{'在 '+record.description+' 中 '+record.annotation+' 新增:' +record.after}} </div>
        <div v-else-if="record.ago!=null&&record.after==null">{{'在 '+record.description+' 中 '+record.annotation+' 删除:' +record.ago}} </div>
        <div v-else-if="record.ago!=null&&record.after!=null">{{'在 '+record.description+' 中 '+record.annotation+' 从 ' +record.ago+' 更新为: '+record.after}} </div>
      </template>




    </a-table>

  </a-card>
</template>

<script>
import { getAction } from '@api/manage'
import moment from 'dayjs'
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import {filterObj} from "@/utils/util";

export default {
  name: 'TslStep',
  mixins:[JeecgListMixin, mixinDevice],
  props:{
    dataId:{
      type: String,
      required: false
    },
  },
  components: {

  },
  data() {
    return {
      historyOption: [],
      columns: [
        {
          title: '#',
          dataIndex: '',
          key:'rowIndex',
          width:60,
          align:"center",
          customRender:function (t,r,index) {
            return parseInt(index)+1;
          }
        },
        {
          title:'修改时间',
          align:"center",
          dataIndex: 'createTime'
        },
        {
          title:'修改人',
          align:"center",
          dataIndex: 'createBy_dictText'
        },
        {
          title:'修改内容',
          align:"center",
          dataIndex: 'content',
          scopedSlots: { customRender: 'content' }
        },

      ],
      url: {
        list: "/review/bussContractRequirementReviewLog/list",
      },
      moment
    }
  },
  created() {

  },
  mounted() {
      this.$nextTick(()=>{
        this.loadData();
      })
  },
  watch: {
    // 监听传入值的变化
    dataId(newValue, oldValue) {
      // 当值变化时，调用方法
      this.loadData();
    }
  },
  computed: {

  },
  methods:{
    getQueryParams() {
      //获取查询条件
      let sqp = {}
      if (this.superQueryParams) {
        sqp['superQueryParams'] = encodeURI(this.superQueryParams)
        sqp['superQueryMatchType'] = this.superQueryMatchType
      }
      var param = Object.assign(sqp, this.queryParam, this.isorter, this.filters);
      // param.field = this.getQueryField();
      param.pageNo = this.ipagination.current;
      param.pageSize = this.ipagination.pageSize;
      return filterObj(param);
    },
    loadData(arg) {
      if(!this.dataId){
        return;
      }
      if (!this.url.list) {
        this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      var params = this.getQueryParams();//查询条件
      params.reviewId= this.dataId
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          this.dataSource = res.result.records || res.result;
          this.dataSourceBack=this.dataSource
          if (res.result.total) {
            this.ipagination.total = res.result.total;
          } else {
            this.ipagination.total = 0;
          }
          //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },

  }
}
</script>

<style scoped>

</style>